package com.zero.yygh.common.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author zero
 * @desc
 * @create 2021/5/10
 */
@Service
public class RabbitService {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 向指定队列发送消息
     * @author zero
     * @date 2021/5/10 12:46
     * @param exchange 交换机
     * @param routingKey routingKey
     * @param message 消息
     * @return boolean
     */
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }

}
